package org.courierframework.core.repository;

import org.courierframework.core.search.Searchable;

import java.io.Serializable;
import java.util.List;

/**
 * Extension of {@link CrudRepository} to provide additional methods to retrieve entities using the pagination abstraction.
 *
 * @param <T>  the persisting type.Typically some kind of entity.
 * @param <ID> the type of the persisting type's idenifier
 * @author long.shiyu
 * @see org.courierframework.core.search.Searchable
 * @since jdk1.7
 */
public interface PaginationRepository<T, ID extends Serializable> extends CrudRepository<T, ID> {
    /**
     * find total records without filter
     *
     * @param searchable an object witch contains search conditions and parameters and java persistence query language
     * @return total records without filter
     */
    Long findTotalRecords(Searchable<T> searchable);

    /**
     * find total records with filter
     *
     * @param searchable an object witch contains search conditions and parameters and java persistence query language
     * @return total records with filter
     */

    Long findFilteredRecordsBySearch(Searchable<T> searchable);

    /**
     * find current page data with filter
     *
     * @param searchable an object witch contains search conditions and parameters and java persistence query language
     * @return current page data
     */
    List<T> findDataBySearch(Searchable<T> searchable);
}
